package com.ttxs.tenant.datasource;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class TenantContextHolder {
    private static final ThreadLocal<String> CONTEXT_HOLDER = new ThreadLocal<>();

    public static String get() {
        return CONTEXT_HOLDER.get();
    }

    public static void set(String tenantName) {
        log.info("切换到数据源：{}", tenantName);
        CONTEXT_HOLDER.set(tenantName);
    }

    public static void remove() {
        CONTEXT_HOLDER.remove();
    }
}
